package com.springcloud.test.controller;

import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Desc TODO
 * ----------------
 * @CLASS_NAME: Controller
 * ----------------
 * @Author jovi
 * ----------------
 * @Date 2020-03-24 14:41
 */
@RestController
public class Controller {

    @Resource
    DiscoveryClient discoveryClient;

    @GetMapping("/dc")
    public String dc() throws InterruptedException {
        //为了触发服务降级逻辑
//        Thread.sleep(5000L);

        List<String> services = discoveryClient.getServices();
        String result = "Services:" + services;
        System.out.println(result);
        return result;
    }
}
